namespace SimpleWebServices.Xml
{
    using System;
    using SimpleWebServices;
    using Xunit;

    public sealed class XmlNamespaceFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<XmlNamespace>()
                .DerivesFrom<ValueObject<XmlNamespace>>()
                .IsConcreteClass()
                .IsSealed()
                .NoDefaultConstructor()
                .Result);
        }

        [Fact]
        public void ctor_string_AbsoluteUri()
        {
            Assert.NotNull(new XmlNamespace("prefix", new AbsoluteUri("http://example.com")));
        }

        [Fact]
        public void ctor_string_AbsoluteUriNull()
        {
            Assert.Throws<ArgumentNullException>(() => new XmlNamespace("prefix", null as AbsoluteUri));
        }

        [Fact]
        public void ctor_stringEmpty_AbsoluteUri()
        {
            Assert.Throws<ArgumentOutOfRangeException>(() => new XmlNamespace(string.Empty, new AbsoluteUri("http://example.com")));
        }

        [Fact]
        public void ctor_stringNull_AbsoluteUri()
        {
            Assert.Throws<ArgumentNullException>(() => new XmlNamespace(null, new AbsoluteUri("http://example.com")));
        }

        [Fact]
        public void prop_Prefix_get()
        {
            string expected = "prefix";
            string actual = new XmlNamespace(expected, new Uri("http://example.com")).Prefix;

            Assert.Equal<string>(expected, actual);
        }

        [Fact]
        public void prop_Prefix_set()
        {
            XmlNamespace obj = new XmlNamespace("prefix", "http://example.com");

            string expected = "prefix";
            obj.Prefix = expected;

            string actual = obj.Prefix;

            Assert.Equal<string>(expected, actual);
        }

        [Fact]
        public void prop_Prefix_setEmpty()
        {
            Assert.Throws<ArgumentOutOfRangeException>(() => new XmlNamespace("prefix", "http://example.com").Prefix = string.Empty);
        }

        [Fact]
        public void prop_Prefix_setNull()
        {
            Assert.Throws<ArgumentNullException>(() => new XmlNamespace("prefix", "http://example.com").Prefix = null);
        }

        [Fact]
        public void prop_Uri_get()
        {
            AbsoluteUri expected = new Uri("http://example.com");
            AbsoluteUri actual = new XmlNamespace("prefix", expected).Uri;

            Assert.Equal<AbsoluteUri>(expected, actual);
        }

        [Fact]
        public void prop_Uri_set()
        {
            XmlNamespace obj = new XmlNamespace("prefix", "http://example.com");

            AbsoluteUri expected = new Uri("http://example.net");
            obj.Uri = expected;

            AbsoluteUri actual = obj.Uri;

            Assert.Equal<AbsoluteUri>(expected, actual);
        }

        [Fact]
        public void prop_Uri_setNull()
        {
            Assert.Throws<ArgumentNullException>(() => new XmlNamespace("prefix", "http://example.com").Uri = null as AbsoluteUri);
        }
    }
}